
MINIMIZE = min

SOURCES = \
  funAux.ml \
  contract.ml \
  parser.ml \
  lexer.ml \
  automaton.ml \
  builder.ml \
  main.ml

OBJS = $(SOURCES:%.ml=%.cmo)

$(MINIMIZE): $(OBJS)
	ocamlc -o $@ unix.cma $^

opt: $(MINIMIZE).opt

$(MINIMIZE).opt: $(OBJS:%.cmo=%.cmx)
	ocamlopt -o $@ unix.cmxa $^

lexer.cmo : parser.cmi
parser.cmo parser.cmx : parser.cmi

%.cmi : %.mli
	ocamlc -c $<

%.cmo %.cmi : %.ml
	ocamlc -c $<

%.cmx %.cmi : %.ml
	ocamlopt -c $<

%.ml : %.mll
	ocamllex $<

%.ml %.mli : %.mly
	ocamlyacc -v $<

%.A.dot %.B.dot %.C.dot: %.con $(MINIMIZE)
	./min $<

%.tex: %.dot
	dot -Txdot $< | dot2tex >$@

%.dvi: %.tex
	latex $<

%.pdf: %.tex
	pdflatex $<

%.ps: %.dvi
	dvips $<

.PHONY: clean dep
clean:
	rm -f parser.mli parser.output *.cmo *.cmi *.cmx $(MINIMIZE){,.opt} *.ps *.dot

dep:
	ocamldep *.ml *.mli >.depend

include .depend
